cd /Users/iwm/appcrawler
pwd
devicelist=`adb devices|awk '{if($2=="device") {print $1}}'`
echo $devicelist

arr=(${devicelist// / })
echo '>>>>>>>>>>>>>>>>>>>.'+${arr[@]}

index=0

appium_server_ports=(4500 4501 4502 4503 4504)
appium_adb_ports=(4600 4601 4602 4603 4504)
ps aux | grep node | awk '{print $2}'|xargs kill -9
sleep 5
for i in ${arr[@]}
do
  echo 'iiiiiiiiiiiiiiii' + $i
  echo 'indexindexindexindexindexindex' + $index
  echo '<<<<<<<<<<<<<<<<<<<<<'+ ${appium_server_ports[$index]}
  let "index+=1"

  nohup /usr/local/bin/node /Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js -p ${appium_server_ports[$index]} -bp ${appium_adb_ports[$index]} -U $i > ./server$index.log &
  sleep 3
  for i in `seq 30`;do
    res=$(lsof -n -i:${appium_server_ports[$index]}|grep "LISTEN")
    echo $res;
    if [ "$res" != "" ];then
      break;
    fi
    sleep 1

  done
  nohup ../waimai_android_$index/run.sh > ./client$index.log &
done
